cmake_minimum_required(VERSION 3.14)
project(CTPQuoteEngine LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 查找必要的包
find_package(Qt5 REQUIRED COMPONENTS Core Test)

# 添加头文件目录
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include/CTP)

# 源文件
set(SOURCES
    src/quote_engine.cpp
)

# 头文件
set(HEADERS
    include/quote_engine.h
    include/quote_defines.h
)

# 创建库
add_library(${PROJECT_NAME} SHARED
    ${SOURCES}
    ${HEADERS}
)

# 链接依赖库
target_link_libraries(${PROJECT_NAME} PRIVATE
    Qt5::Core
)

# 启用测试
enable_testing()

# 添加测试源文件
set(TEST_SOURCES
    tests/quote_engine_test.cpp
)

# 创建测试可执行文件
add_executable(${PROJECT_NAME}_test ${TEST_SOURCES})

# 链接测试依赖
target_link_libraries(${PROJECT_NAME}_test PRIVATE
    ${PROJECT_NAME}
    Qt5::Core
    Qt5::Test
)

# 添加测试
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)

# 添加 demo ��目录
add_subdirectory(demo)

# 添加编译定义
if(WIN32)
    target_compile_definitions(${PROJECT_NAME} 
        PRIVATE 
        CTPQUOTEENGINE_LIBRARY
    )
endif() 